home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 90 / CD Actual 90.iso / Software3D / K-3D / k3d-0.4.2.1 / shaders / k3d_screen.sl < prev    next >
Encoding:
Text File  |  2004-07-23  |  1.3 KB  |  44 lines

  1. /* screen.sl - RenderMan compatible shader for a metalic screen.
  2.  * (c) Pixar (appears in _RenderMan Companion_)
  3.  *
  4.  *
  5.  * DESCRIPTION:
  6.  *   Makes a surface that looks like a metal screen.  Strips of metal run
  7.  *   parallel to lines of s and t.  You can adjust the Ka, Kd, Ks, etc.
  8.  *   to change the material appearance.
  9.  * 
  10.  * PARAMETERS:
  11.  *   Ka, Kd, Ks, roughness, specularcolor - work just like the plastic shader
  12.  *   frequency - how many cycles of screen in st space
  13.  *   density - how much of each cycle is opaque?
  14.  *
  15.  * WARNINGS:
  16.  *   No antialiasing is performed here.
  17.  *
  18.  * The RenderMan (R) Interface Procedures and RIB Protocol are:
  19.  *     Copyright 1988, 1989, Pixar.  All rights reserved.
  20.  * RenderMan (R) is a registered trademark of Pixar.
  21.  *
  22.  */
  23.  
  24. surface k3d_screen(float Ka = 1, Kd = 0.75, Ks = 0.4, roughness = 0.1;
  25.            color specularcolor = 1;
  26.            float density = 0.25, frequency = 20;)
  27. {
  28.   normal Nf;
  29.  
  30.   if(mod(s * frequency, 1) < density || mod(t * frequency, 1) < density)
  31.     {
  32.       Oi = 1;
  33.       Nf = faceforward(normalize(N), I);
  34.       Ci =
  35.     Os * (Cs * (Ka * ambient() + Kd * diffuse(Nf)) +
  36.           specularcolor * Ks * specular(Nf, -normalize(I), roughness));
  37.     }
  38.   else
  39.     {
  40.       Oi = 0;
  41.       Ci = 0;
  42.     }
  43. }
  44.